home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Estructuras básicas / HelloCenteredAlignment / HelloCenteredAlignment.cs next >
Encoding:
Text File  |  2002-04-22  |  1.1 KB  |  33 lines

  1. //-----------------------------------------------------
  2. // HelloCenteredAlignment.cs ⌐ 2001 by Charles Petzold
  3. //-----------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class HelloCenteredAlignment: Form
  9. {
  10.      public static void Main()
  11.      {
  12.           Application.Run(new HelloCenteredAlignment());
  13.      }
  14.      public HelloCenteredAlignment()
  15.      {
  16.           Text = "Saludo centrado mediante alineaci≤n de cadenas";
  17.           BackColor = SystemColors.Window;
  18.           ForeColor = SystemColors.WindowText;
  19.           ResizeRedraw = true;
  20.      }
  21.      protected override void OnPaint(PaintEventArgs pea)
  22.      {
  23.           Graphics     grfx   = pea.Graphics;
  24.           StringFormat strfmt = new StringFormat();
  25.  
  26.           strfmt.Alignment     = StringAlignment.Center;
  27.           strfmt.LineAlignment = StringAlignment.Center;
  28.  
  29.           grfx.DrawString("íHola, mundo!", Font, new SolidBrush(ForeColor), 
  30.                           ClientSize.Width / 2, ClientSize.Height / 2, 
  31.                           strfmt);
  32.      }
  33. }